/*
 * This file is part of Catfish.
 * Copyright (C) 2010 Namazu Studios LLC
 * 
 * Catfish is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of 
 * the License, or (at your option) any later version.
 * 
 * Catfish is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with Catfish.  If not, please visit:
 *  
 * http://www.gnu.org/licenses/
 *  
 */
package com.namazustudios.catfish.datasource;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.EntityNotFoundException;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Transaction;
import com.google.inject.Inject;
import com.namazustudios.catfish.DataSource;

/**
 * Directly delegates all calls to the DatastoreService object.
 * 
 * @author patricktwohig
 * 
 */
public class DirectDataSource implements DataSource {

	@Inject
	private DatastoreService datastore;

	@Override
	public void delete(Iterable<Key> keys) {
		datastore.delete(keys);
	}

	@Override
	public void delete(Key... keys) {
		datastore.delete(keys);
	}

	@Override
	public void delete(Transaction txn, Iterable<Key> keys) {
		datastore.delete(txn, keys);
	}

	@Override
	public void delete(Transaction txn, Key... keys) {
		datastore.delete(txn, keys);
	}

	@Override
	public Map<Key, Entity> get(Iterable<Key> keys) {
		return datastore.get(keys);
	}

	@Override
	public Entity get(Key key) throws EntityNotFoundException {
		return datastore.get(key);
	}

	@Override
	public Map<Key, Entity> get(Key... keys) {
		return datastore.get(Arrays.asList(keys));
	}

	@Override
	public Map<Key, Entity> get(Transaction txn, Iterable<Key> keys) {
		return datastore.get(txn, keys);
	}

	@Override
	public Entity get(Transaction txn, Key key) throws EntityNotFoundException {
		return datastore.get(txn, key);
	}

	@Override
	public Map<Key, Entity> get(Transaction txn, Key... keys) {
		return datastore.get(txn, Arrays.asList(keys));
	}

	@Override
	public List<Key> put(Entity... entities) {
		return datastore.put(Arrays.asList(entities));
	}

	@Override
	public List<Key> put(Iterable<Entity> entities) {
		return datastore.put(entities);
	}

	@Override
	public List<Key> put(Transaction txn, Entity... entities) {
		return datastore.put(txn, Arrays.asList(entities));
	}

	@Override
	public List<Key> put(Transaction txn, Iterable<Entity> entities) {
		return datastore.put(txn, entities);
	}

}
